package com.example.deeplearningjavafrombug.regex.lesson4;

import org.junit.Test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Client {

    @Test
    public void test1() {
        String data = "{\"version\":\"1.0\",\"data\":\"some data\"}";
        Pattern pattern = Pattern.compile("\"version\":\"(.*)\"");
        Matcher matcher = pattern.matcher(data);
        while (matcher.find()) {
            if (matcher.groupCount() >= 1) {
                System.out.println(matcher.group(1));
            }
        }
    }

    @Test
    public void test2() {
        String data = "{\"version\":\"1.0\",\"data\":\"some data\"}";
        Pattern pattern = Pattern.compile("\"version\":\"(.*?)\"");
        Matcher matcher = pattern.matcher(data);
        while (matcher.find()) {
            if (matcher.groupCount() >= 1) {
                System.out.println(matcher.group(1));
            }
        }
    }


}
